{% extends 'uc_base.html' %}
{% load staticfiles %}
{% block uc_content %}
    <div class="row">
        <div class="col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    Dynamic Table
                </header>
                <table class="table table-striped border-top" id="sample_1">
                    <thead>
                    <tr>
                        <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                        <th class="hidden-phone">问题</th>
                        <th class="hidden-phone">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {# 所有待审核的题目： Questions.objects.exclude(status=True) #}
                    {% for question in questions %}
                        <tr class="odd gradeX">
                            <td><input type="checkbox" class="checkboxes" value="1" /></td>
                            <td><a href="javascript:void(0);" title="{{ question.content|safe }}">{{ question.title }}</a></td>
                            <td><input type="button" value="通过" onclick="pass(this,{{ question.id }})"></td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </section>
        </div>
    </div>
    <!-- page end-->
{% endblock %}
{% block load_js %}
    <script>
        function pass(obj,id) {
            $.ajax(
                {
                    // 将question的状态改为True
                    // 此接口权限=> can_change_question_status
                    url:'/uc/approval/'+id+'/',
                    success: function (data) {
                        // 即将删除的那一行数据
                        mynode = obj.parentNode.parentNode;
                        mynode.parentNode.removeChild(mynode);
                    }
                }
            )
        }
    </script>
    <script type="text/javascript" src="{% static 'assets/data-tables/jquery.dataTables.js' %}"></script>
    <script type="text/javascript" src="{% static 'assets/data-tables/DT_bootstrap.js' %}"></script>
    <script src="{% static 'js/dynamic-table.js' %}"></script>
{% endblock %}